package com.techeritem.controller;


import com.techeritem.entity.Login;
import com.techeritem.service.LoginService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api")
@EnableAutoConfiguration
public class LoginController {
    @Autowired
    private LoginService loginService;

    @PostMapping
    public ResponseEntity<String>  authenticate(@RequestBody Login login) {
        if (loginService.authenticate(login)) {
            return ResponseEntity.ok("Authentication successful");
        } else {
            return ResponseEntity.badRequest().body("Invalid credentials");
        }
    }
}



